﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/User.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Site.Areas.User.ViewModels.DemandViewModels>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Site.Areas.User.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%=ViewData["stringTitle"]%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <form action="/User/demand" method="post" name="adminForm">
    <table width="100%">
        <tr>
            <td align="left">
                Tìm nhanh
                <%= Html.TextBox("Keyword", Model.Keyword) %>
                <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
            </td>
            <td align="right">
                <%--<%=Html.DropDownList("DemandTypeID", new SelectList(Model.DemandTypes, "ID", "Name", Model.CurrentDemandTypes).ToList(), "- Chọn loại nhu cầu -", new {onchange="document.adminForm.submit();" })%>--%>
                <%=Html.DropDownList("CurrentCat", new SelectList(Model.Categories, "ID", "Name", Model.CurrentCat), "-- Chuyên mục --", new
{
    onchange = "document.adminForm.submit();"
})%>
                <%--<%=Html.DropDownList("CurrentPubStatus", Model.ListStatusPub, "-- Trạng thái hiển thị --", new { onchange = "document.adminForm.submit();" })%>--%>
            </td>
        </tr>
    </table>
    <table width="100%" class="tblprice">
        <thead>
            <tr>
                <th width="30" align="right" align="center">
                    STT
                </th>
                <th style="width: 50px" align="center">
                    <%= Html.Sort("Mã tin", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th>
                    <%= Html.Sort("Tiêu đề", "Title", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th style="width: 120px" align="center">
                    <%= Html.Sort("Thuộc chuyên mục", "CatID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th style="width: 90px" align="center">
                    <%= Html.Sort("Ngày thêm", "AddDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th width="30" align="center">
                    Sửa
                </th>
                <th width="30" align="center">
                    Xóa
                </th>
            </tr>
        </thead>
        <tbody>
            <% 
                int i = 0;
                foreach (var item in Model.Demand)
                {
                    i++;
            %>
            <tr>
                <td align="center">
                    <%= i.ToString() %>
                </td>
                <td align="center">
                    <%= Html.Encode(item.ID) %>
                </td>
                <td>
                    <a href="/demand/details/<%=item.ID %>/<%=Html.ToUrlFriendly(item.Title)%>">
                        <%=Html.Encode(item.Title) %>
                    </a>
                    <%-- <%= Html.ActionLink(item.Title, "Details", new { id = item.ID, area = "" })%>   --%>
                </td>
                <td>
                    <%= Html.Encode(item.DemandCategory.Name)%>
                </td>
                <td align="center">
                    <%= Html.Encode(item.AddDate != null ? item.AddDate.Value.ToString("dd/MM/yyyy") : "--")%>
                </td>
                <td align="center">
                    <%= Html.ActionImage("Sửa", "icon-24-edit.png","User/Demand", "Edit", new Dictionary<string, object>() { { "id", item.ID } })%>
                </td>
                <td align="center">
                    <%= Html.ActionImage("Xóa", "icon-24-delete.png", "User/Demand", "Delete", new Dictionary<string, object>() { { "id", item.ID } })%>
                </td>
            </tr>
            <% } %>
        </tbody>
    </table>
    <%= Html.Hidden("order")%>
    <%= Html.Hidden("orderDir")%>
    <div class="pagebarUTH f_r">
        Trang
        <%= Model.Demand.PageNumber%>/<%= Model.Demand.PageCount%>
        <%= Html.Pager(Model.Demand.PageSize, Model.Demand.PageNumber, Model.Demand.TotalItemCount)%>
        <label>
            Hiển thị #</label>
        <%
            int[] pageSizeList = { 1, 5, 10, 15, 20, 25, 50, 100 };
        %>
        <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Demand.PageSize), new { onchange = "document.adminForm.submit();" })%>
    </div>
    </form>
    <% } %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Thêm mới", "/User/demand/Create", "new")%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Danh sách tin nhu cầu cần mua/thuê
</asp:Content>
